using System;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using System.Text;

using PickGold;
using PickGold.Database;

namespace PickGold.Entities.Table
{
    public class CExtendSuraNews : CExtendTable
    {
        //
        public const string ENTITY_NAME = "te_sys_sura_news";
        public const string ENTITY_ALIAS = "sura_news";
        //
        public const string SURA_ID = CBaseSuraInfo.ENTITY_KEY;
        public const string NEWS_ID = CBaseNewsInfo.ENTITY_KEY;
        public const string ITEM_NOTE = "item_note";
        //
        private SExtendSuraNews _ = null;
        //
        public CExtendSuraNews() : base(ENTITY_NAME, ENTITY_ALIAS) { }
        public CExtendSuraNews(CDatabase db) : base(db, ENTITY_NAME, ENTITY_ALIAS) { }
        public CExtendSuraNews(string alias) : base(ENTITY_NAME, alias) { }
        public CExtendSuraNews(CDatabase db, string alias) : base(db, ENTITY_NAME, alias) { }
        //
        protected override void SetSchema()
        {
            this.SetSchema(new SExtendSuraNews());
        }
        protected void SetSchema(SExtendSuraNews s)
        {
            this._ = s;
            base.SetSchema(s);
        }
        //
        protected override void PreInitSchema()
        {
            base.PreInitSchema();
            this._DataTable.Columns.Add(SURA_ID, typeof(long)).DefaultValue = this._.SuraID;
            this._DataTable.Columns.Add(NEWS_ID, typeof(long)).DefaultValue = this._.NewsID;
            this._DataTable.Columns.Add(ITEM_NOTE, typeof(string)).MaxLength = 50;
        }
        //
        protected override List<DataColumn> AddKeyColumn()
        {
            List<DataColumn> list = base.AddKeyColumn();
            list.Add(this._DataTable.Columns[SURA_ID]);
            list.Add(this._DataTable.Columns[NEWS_ID]);
            return list;
        }
        //
        #region Property
        //
        public long SuraID
        {
            set
            {
                this._.SuraID = value;
                this.SetValue(SURA_ID, value);
            }
            get
            {
                return this._.SuraID;
            }
        }
        //
        public long NewsID
        {
            set
            {
                this._.NewsID = value;
                this.SetValue(NEWS_ID, value);
            }
            get
            {
                return this._.NewsID;
            }
        }
        //
        public string ItemNote
        {
            set
            {
                this._.ItemNote = value;
                this.SetValue(ITEM_NOTE, value);
            }
            get
            {
                return this._.ItemNote;
            }
        }
        //
        #endregion
        //
        public override bool MoveTo(int position)
        {
            if (!base.MoveTo(position))
                return false;
            this._.SuraID = this.GetValue<long>(SURA_ID);
            this._.NewsID = this.GetValue<long>(NEWS_ID);
            this._.ItemNote = this.GetValue<string>(ITEM_NOTE);
            return true;
        }
        //
    }
    //
    public class SExtendSuraNews : SExtendTable
    {
        //
        public long SuraID = -1;
        public long NewsID = -1;
        public string ItemNote = null;
        //
    }
    //
}
//
